#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2018, Intel Corporation
#
#
# libpmempool_backup/TEST7 -- test backup to pool which already exists
#

. ../unittest/unittest.sh

require_test_type medium

require_fs_type pmem non-pmem

setup

. ./common.sh

for (( i=0; i<${#POOL_TYPES[@]}; i++ ));
do
	backup_cleanup

	POOLFILE=$DIR/pool.${POOL_TYPES[$i]}
	rm -f $POOLFILE

	# create source poolset
	expect_normal_exit $PMEMPOOL$EXESUFFIX create ${POOL_TYPES[$i]} \
		"${POOL_CREATE_PARAMS[$i]}" --size 20M $POOLFILE

	# create backup pool file
	truncate -s 20M $POOLFILE$BACKUP
	backup_and_compare $POOLFILE ${POOL_TYPES[$i]}

	# create too small backup pool file
	truncate -s 10M $POOLFILE$BACKUP
	backup_and_compare $POOLFILE ${POOL_TYPES[$i]}
done

mv $OUT_TEMP $OUT

check

pass
